<template>
  <div class="data-v-cus-bar1">
    <div v-for="(s, i) in series" :key="i" class="bar">
      <div class="bar-name">{{ s.name | upper }}</div>
      <div class="bar-item">
        <div class="bar-item-inner" :style="sty(s)"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "cus-bar1",
  props: ["series", "maxValue", "color"],
  filters: {
    upper(v) {
      return String(v).toUpperCase();
    }
  },
  methods: {
    getPercentage(value) {
      return value / this.maxValue;
    },
    sty(s) {
      return {
        width: this.getPercentage(s.value) * 100 + "%"
      };
    }
  }
};
</script>

<style lang="less">
.data-v-cus-bar1 {
  // height: 400px;


  // display: flex;
  .bar {
    display: flex;
    height: 20px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    & + .bar {
      margin-top: 20px;
    }
    .bar-name {
      width: 100px;
      padding: 0 5px;
      border-left: 3px solid var(--color);
      color: rgba(255, 255, 255, 0.8);
      text-align: right;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .bar-item {
      flex: 1;
      height: 12px;
      background: #26282b;
    }
    .bar-item-inner {
      width: 0;
      height: 100%;
      background:  var(--color);
      border-right: 1px solid #fff;
      transition: 0.25s;
    }
  }
}
</style>
